package com.briup.jz.service.impl;

import com.briup.jz.bean.User;
import com.briup.jz.bean.extend.UserExtend;
import com.briup.jz.dao.UserMapper;
import com.briup.jz.dao.extend.UserExtendMapper;
import com.briup.jz.service.ICheckService;
import com.briup.jz.utils.CustomerException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program：jz
 * @description：审核业务实现类
 * @author：axin
 * @create：Created in 2020/6/15 17:31
 */
@Service
public class CheckServiceImpl implements ICheckService {
    @Resource
    private UserExtendMapper userExtendMapper;
    @Resource
    private UserMapper userMapper;
    /**
     * description:通过状态查找员工
     *
     * @param status
     */
    @Override
    public List<UserExtend> findAllByStatus(String status) {
        return userExtendMapper.selectByStatus(status);
    }

    /**
     * description:更新员工审核状态
     *
     * @param id
     * @param status
     */
    @Override
    public void updateUserStatus(Long id, String status) throws CustomerException {
        userExtendMapper.updateUserStatus(id,status);
    }

    /**
     * description:提现审核
     *
     * @param id
     * @param money
     */
    @Override
    public boolean withDarwal(Long id, Long money) throws CustomerException {
        User user = userMapper.selectByPrimaryKey(id);
        String balence = user.getBalance();
        if(balence==null){
            return false;
        }else{
            long balenceint = Long.valueOf(balence).longValue();
            if(balenceint>=money)
                return true;
            else
                return false;
        }
    }
}
